<?php
namespace App\Validate\System;
use App\Validate\ValidateInterface;

/**
* 创建验证器
* @create 2023-07-20 11:10:00
*/
class SysUserValidate extends ValidateInterface {

    static $rules       = [ /* 'mobile' => 'required|regex:/^1\d{10}$/' */ 
        'user_id' => 'required',
        'dept_id' => 'required',
        'user_name' => 'required',
        'nick_name' => 'required',
        'user_type' => 'required|in:00',
        'email' => 'required',
        'phonenumber' => 'required',
        'sex' => 'required|in:0,1,2',
        'avatar' => 'required',
        'password' => 'required',
        'status' => 'required|in:0,1',
        'del_flag' => 'required|in:0,2',
        'login_ip' => 'required',
        'login_date' => 'required',
        'create_by' => 'required',
        'create_time' => 'required',
        'update_by' => 'required',
        'update_time' => 'required',
        'remark' => 'required',
    ];
    static $rules_format = [ /* 'mobile.regex' => '手机号格式不对' */ 
    ];
    static $rules_str     = [ /* 'mobile' => '手机号' */ 
        'user_id' => '用户ID',
        'dept_id' => '部门ID',
        'user_name' => '用户账号',
        'nick_name' => '用户昵称',
        'user_type' => '用户类型（00系统用户）',
        'email' => '用户邮箱',
        'phonenumber' => '手机号码',
        'sex' => '用户性别（0男 1女 2未知）',
        'avatar' => '头像地址',
        'password' => '密码',
        'status' => '帐号状态（0正常 1停用）',
        'del_flag' => '删除标志（0代表存在 2代表删除）',
        'login_ip' => '最后登录IP',
        'login_date' => '最后登录时间',
        'create_by' => '创建者',
        'create_time' => '创建时间',
        'update_by' => '更新者',
        'update_time' => '更新时间',
        'remark' => '备注',
    ];

    /**
     * 验证场景，一般store（新增）、update（修改）
     * 
     */
     public static function scene($scene) {
         self::$scene();
     }

     /** 验证规则 store,新增场景 */
     public static function store() {
        // ignore   : 'user_id',
        // nullable : 'dept_id','user_type','email','phonenumber','sex','avatar','password','status','del_flag','login_ip','login_date','create_by','create_time','update_by','update_time','remark',
        static::validate(['user_name','nick_name',]);
     }
 
     /** 验证规则 update,修改场景 */
     public static function update() {
        // ignore   : 
        // nullable : 'dept_id','user_type','email','phonenumber','sex','avatar','password','status','del_flag','login_ip','login_date','create_by','create_time','update_by','update_time','remark',
        static::validate(['user_id','user_name','nick_name',]);
        // 可以二次校验
        // static::validate(request('bless_type') == 1 ? ['friend_name'] : ['birthday']);
     }

}